<template>
	<div id="mystudent">
		<!-- 面包屑导航 -->
		<el-breadcrumb separator-class="el-icon-arrow-right" style="margin-bottom: 20px;">
			<el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
			<el-breadcrumb-item :to="{ path: '/welcome' }">网络档案管理系统</el-breadcrumb-item>
			<el-breadcrumb-item>我的学生</el-breadcrumb-item>
		</el-breadcrumb>
		<el-card>
			<!-- 搜索 -->
			<el-row>
				<el-col style="margin-bottom: 30px;">
					<el-form :inline="true" :model="formInline" class="demo-form-inline">
						<el-form-item label="姓名">
							<el-input v-model="formInline.SName"></el-input>
						</el-form-item>
						<el-form-item label="QQ">
							<el-input v-model="formInline.QQ"></el-input>
						</el-form-item>
						<el-form-item label="手机号">
							<el-input v-model="formInline.Phone"></el-input>
						</el-form-item>
						<el-form-item label="咨询师">
							<el-select v-model="formInline.AskerId">
								<el-option label="--所有咨询师--" value="0"></el-option>
								<el-option v-for="item in aslist" :label="item.AskerName" :value="item.AskerId">
								</el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="是否缴费" prop="IsPay" label-width="80px">
							<el-select v-model="formInline.IsPay">
								<el-option label="--是--" value="1"></el-option>
								<el-option label="--否--" value="0"></el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="是否无效" prop="IsValid" label-width="80px">
							<el-select v-model="formInline.IsValid">
								<el-option label="--是--" value="1"></el-option>
								<el-option label="--否--" value="0"></el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="回访情况" prop="IsReturnVisit" label-width="80px">
							<el-select v-model="formInline.IsReturnVisit">
								<el-option label="--是--" value="1"></el-option>
								<el-option label="--否--" value="0"></el-option>
							</el-select>
						</el-form-item>
						<el-form-item label="创建时间">
							<el-input type="date" v-model="formInline.CreateTime1"></el-input>
						</el-form-item>
						<el-form-item label="-">
							<el-input type="date" v-model="formInline.CreateTime2"></el-input>
						</el-form-item>
						<el-form-item label="上门时间">
							<el-input type="date" v-model="formInline.HomeTime1"></el-input>
						</el-form-item>
						<el-form-item label="-">
							<el-input type="date" v-model="formInline.HomeTime2"></el-input>
						</el-form-item>
						<el-form-item>
							<el-button type="primary" @click="onSubmit"><i class="el-icon-search"></i></el-button>
						</el-form-item>
					</el-form>
				</el-col>
			</el-row>
			<!-- 显示 -->
			<el-table :data="tableData" id="out-table"  @selection-change="handleSelectionChange" style="width: 100%" max-height="500">
				<el-table-column type="selection" width="55">
				</el-table-column>
				<el-table-column fixed prop="SId" v-if="TableShow.SId" label="学生编号" width="100">
				</el-table-column>
				<el-table-column align="left">
					<template slot="header" slot-scope="scope">
						<el-button @click="stuadddialogFormVisible=true"><i class="el-icon-circle-plus"></i>添加</el-button>
						<el-button @click="TableRowVisible=true"><i class="el-icon-circle-plus"></i>设置</el-button>
						<el-button @click="downloadExcel"><i class="el-icon-circle-plus"></i>导出Excel</el-button>
						<el-button @click="EditRo"><i class="el-icon-circle-plus"></i>批量操作</el-button>
					</template>
					<el-table-column prop="SName" v-if="TableShow.SName" label="姓名" width="120">
					</el-table-column>
					<el-table-column prop="Sex" v-if="TableShow.Sex" label="性别" width="120">
					</el-table-column>
					<el-table-column prop="Age" v-if="TableShow.Age" label="年龄" width="120">
					</el-table-column>
					<el-table-column prop="Phone" v-if="TableShow.Phone" label="手机" width="150">
					</el-table-column>
					<el-table-column prop="QQ" v-if="TableShow.QQ" label="QQ" width="150">
					</el-table-column>
					<el-table-column prop="WX" v-if="TableShow.WX" label="微信" width="150">
					</el-table-column>
					<el-table-column prop="SAddress" v-if="TableShow.SAddress" label="地址" width="200">
					</el-table-column>
					<el-table-column prop="StuStatus" v-if="TableShow.StuStatus" label="学生状态" width="120">
					</el-table-column>
					<el-table-column prop="MsgScource" v-if="TableShow.MsgScource" label="消息来源" width="120">
					</el-table-column>
					<el-table-column prop="ScourceUrl" v-if="TableShow.ScourceUrl" label="来源地址" width="200">
					</el-table-column>
					<el-table-column prop="ScourceKeyWord" v-if="TableShow.ScourceKeyWord" label="来源关键字" width="120">
					</el-table-column>
					<el-table-column prop="AskerName" v-if="TableShow.AskerName" label="咨询师姓名" width="120">
					</el-table-column>
					<el-table-column prop="FromPart" v-if="TableShow.FromPart" label="来源部门" width="120">
					</el-table-column>
					<el-table-column prop="IsBaoBei" v-if="TableShow.IsBaoBei" label="是否报备" width="120">
						<template slot-scope="scope">
							<el-tag type="danger" v-if="scope.row.IsBaoBei===0">否</el-tag>
							<el-tag type="success" v-else>是</el-tag>
						</template>
					</el-table-column>
					<el-table-column prop="Learnforward" v-if="TableShow.Learnforward" label="课程方向" width="120">
					</el-table-column>
					<el-table-column prop="IsValid" v-if="TableShow.IsValid" label="是否无效" width="120">
						<template slot-scope="scope">
							<el-tag type="danger" v-if="scope.row.IsValid===0">否</el-tag>
							<el-tag type="success" v-else>是</el-tag>
						</template>
					</el-table-column>
					<el-table-column prop="Record" v-if="TableShow.Record" label="打分" width="120">
					</el-table-column>
					<el-table-column prop="IsReturnVisit" v-if="TableShow.IsReturnVisit" label="是否回访" width="120">
						<template slot-scope="scope">
							<el-tag type="danger" v-if="scope.row.IsReturnVisit===0">否</el-tag>
							<el-tag type="success" v-else>是</el-tag>
						</template>
					</el-table-column>
					<el-table-column prop="FirstVisitTime" v-if="TableShow.FirstVisitTime" label="首次回访时间" width="170">
					</el-table-column>
					<el-table-column prop="IsHome" v-if="TableShow.IsHome" label="是否上门" width="120">
						<template slot-scope="scope">
							<el-tag type="danger" v-if="scope.row.IsHome===0">否</el-tag>
							<el-tag type="success" v-else>是</el-tag>
						</template>
					</el-table-column>
					<el-table-column prop="HomeTime" v-if="TableShow.HomeTime" label="上门时间" width="170">
					</el-table-column>
					<el-table-column prop="LostVaild" v-if="TableShow.LostVaild" label="无效原因" width="120">
					</el-table-column>
					<el-table-column prop="IsPay" v-if="TableShow.IsPay" label="是否缴费" width="120">
						<template slot-scope="scope">
							<el-tag type="danger" v-if="scope.row.IsPay===0">否</el-tag>
							<el-tag type="success" v-else>是</el-tag>
						</template>
					</el-table-column>
					<el-table-column prop="PayTime" v-if="TableShow.PayTime" label="缴费时间" width="170">
					</el-table-column>
					<el-table-column prop="Money" v-if="TableShow.PayTime" label="缴费金额" width="120">
					</el-table-column>
					<el-table-column prop="IsReturnMony" v-if="TableShow.IsReturnMony" label="是否退费" width="120">
						<template slot-scope="scope">
							<el-tag type="danger" v-if="scope.row.IsReturnMony===0">否</el-tag>
							<el-tag type="success" v-else>是</el-tag>
						</template>
					</el-table-column>
					<el-table-column prop="IsInClass" v-if="TableShow.IsReturnMony" label="是否进班" width="120">
						<template slot-scope="scope">
							<el-tag type="danger" v-if="scope.row.IsInClass===0">否</el-tag>
							<el-tag type="success" v-else>是</el-tag>
						</template>
					</el-table-column>
					<el-table-column prop="InClassTime" v-if="TableShow.InClassTime" label="进班时间" width="120">
					</el-table-column>
					<el-table-column prop="InClassContent" v-if="TableShow.InClassContent" label="进班备注" width="120">
					</el-table-column>
					<el-table-column prop="ReturnMoneyReason" v-if="TableShow.ReturnMoneyReason" label="退费原因"
						width="200">
					</el-table-column>
					<el-table-column prop="PreMoney" v-if="TableShow.PreMoney" label="定金金额" width="120">
					</el-table-column>
					<el-table-column prop="PreMoneyTime" v-if="TableShow.PreMoneyTime" label="定金时间" width="170">
					</el-table-column>
					<el-table-column prop="NetPushId" v-if="TableShow.NetPushId" label="就业方向" width="170">
					</el-table-column>
					<el-table-column prop="CreateTime" v-if="TableShow.CreateTime" label="创建时间" width="170">
					</el-table-column>
				</el-table-column>
				<!-- 操作 -->
				<el-table-column fixed="right" label="操作" width="300">
					<template slot-scope="scope">
						<el-button icon="el-icon-thumb" @click.native.prevent="Look(scope.row)" type="text"
							size="small">
							查看
						</el-button>
						<el-button icon="el-icon-edit" @click.native.prevent="EditStu(scope.row)" type="text"
							size="small">
							编辑
						</el-button>
						<el-button icon="el-icon-delete" @click.native.prevent="DELETE(scope.row.SId)" type="text"
							size="small">
							删除
						</el-button>
						<el-button icon="el-icon-map-location" @click.native.prevent="AddFollow(scope.row)" type="text"
							size="small">
							跟踪
						</el-button>
						<el-button icon="el-icon-notebook-1" @click.native.prevent="deleteRow(scope.row.SId)"
							type="text" size="small">
							日志
						</el-button>
					</template>
				</el-table-column>
			</el-table>
			<!-- 分页 -->
			<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="page"
				background :page-sizes="[5, 10, 15, 20]" :page-size="limit"
				layout="total, sizes, prev, pager, next, jumper" :total="count">
			</el-pagination>
			<!-- 新增 -->
			<el-dialog title="新增学生" :visible.sync="stuadddialogFormVisible" @close="AClose">
				<el-form :model="stuaddform" ref="stuaddFormRef">
					<el-form-item label="姓名" prop="SName" label-width="80px">
						<el-input v-model="stuaddform.SName"></el-input>
					</el-form-item>
					<el-form-item label="性别" prop="Sex" label-width="80px">
						<el-input v-model="stuaddform.Sex"></el-input>
					</el-form-item>
					<el-form-item label="年龄" prop="Age" label-width="80px">
						<el-input v-model="stuaddform.Age"></el-input>
					</el-form-item>
					<el-form-item label="手机" prop="Phone" label-width="80px">
						<el-input v-model="stuaddform.Phone"></el-input>
					</el-form-item>
					<el-form-item label="所有咨询师">
						<el-select v-model="stuaddform.AskerId">
							<el-option label="--所有咨询师--" value="0"></el-option>
							<el-option v-for="item in aslist" :label="item.AskerName" :value="item.AskerId"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="QQ" prop="QQ" label-width="80px">
						<el-input v-model="stuaddform.QQ"></el-input>
					</el-form-item>
					<el-form-item label="来源渠道" prop="MsgScource" label-width="80px">
						<el-input v-model="stuaddform.MsgScource"></el-input>
					</el-form-item>
					<el-form-item label="来源网站" prop="ScourceUrl" label-width="80px">
						<el-input v-model="stuaddform.ScourceUrl"></el-input>
					</el-form-item>
					<el-form-item label="来源关键字" prop="ScourceKeyWord" label-width="80px">
						<el-input v-model="stuaddform.ScourceKeyWord"></el-input>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button v-on:click="stuadddialogFormVisible = false">取 消</el-button>
					<el-button type="primary" @click="SUREADD">确 定</el-button>
				</div>
			</el-dialog>
			<!-- 设置 -->
			<el-dialog :close-on-click-modal="false" title="显示列" :visible.sync="TableRowVisible">
				<el-checkbox v-model="TableShow.SId">序号</el-checkbox>
				<el-checkbox v-model="TableShow.SName">学生姓名</el-checkbox>
				<el-checkbox v-model="TableShow.Age">年龄</el-checkbox>
				<el-checkbox v-model="TableShow.Sex">性别</el-checkbox>
				<el-checkbox v-model="TableShow.Phone">电话</el-checkbox>
				<el-checkbox v-model="TableShow.AskerName">咨询师</el-checkbox>
				<el-checkbox v-model="TableShow.SAddress">地址</el-checkbox>
				<el-checkbox v-model="TableShow.QQ">QQ</el-checkbox>
				<el-checkbox v-model="TableShow.WX">微信</el-checkbox>
				<el-checkbox v-model="TableShow.StuStatus">学生状态</el-checkbox>
				<el-checkbox v-model="TableShow.MsgScource">消息来源</el-checkbox>
				<el-checkbox v-model="TableShow.ScourceUrl">来源地址</el-checkbox>
				<el-checkbox v-model="TableShow.ScourceKeyWord">来源关键字</el-checkbox>
				<el-checkbox v-model="TableShow.FromPart">来源部门</el-checkbox>
				<el-checkbox v-model="TableShow.IsBaoBei">是否报备</el-checkbox>
				<el-checkbox v-model="TableShow.Learnforward">课程方向</el-checkbox>
				<el-checkbox v-model="TableShow.IsValid">是否无效</el-checkbox>
				<el-checkbox v-model="TableShow.IsHome">是否上门</el-checkbox>
				<el-checkbox v-model="TableShow.IsPay">是否缴费</el-checkbox>
				<el-checkbox v-model="TableShow.Record">打分</el-checkbox>
				<el-checkbox v-model="TableShow.IsReturnVisit">是否回访</el-checkbox>
				<el-checkbox v-model="TableShow.FirstVisitTime">首次回访时间</el-checkbox>
				<el-checkbox v-model="TableShow.HomeTime">上门时间</el-checkbox>
				<el-checkbox v-model="TableShow.LostVaild">无效原因</el-checkbox>
				<el-checkbox v-model="TableShow.Money">缴费金额</el-checkbox>
				<el-checkbox v-model="TableShow.PayTime">缴费时间</el-checkbox>
				<el-checkbox v-model="TableShow.IsReturnMony">是否退费</el-checkbox>
				<el-checkbox v-model="TableShow.IsInClass">是否进班</el-checkbox>
				<el-checkbox v-model="TableShow.InClassTime">进班时间</el-checkbox>
				<el-checkbox v-model="TableShow.InClassContent">进班备注</el-checkbox>
				<el-checkbox v-model="TableShow.ReturnMoneyReason">退费原因</el-checkbox>
				<el-checkbox v-model="TableShow.PreMoney">定金金额</el-checkbox>
				<el-checkbox v-model="TableShow.PreMoneyTime">定金时间</el-checkbox>
				<el-checkbox v-model="TableShow.NetPushId">就业方向</el-checkbox>
				<el-checkbox v-model="TableShow.CreateTime">创建时间</el-checkbox>
			</el-dialog>
			<!-- 批量编辑 -->
			<el-dialog title="编辑角色" :visible.sync="editakdialogFormVisible">
				<el-form :model="editakform">
					<el-form-item label="所有咨询师">
						<el-select v-model="editakform.AskerId">
							<el-option label="--所有咨询师--" value="0"></el-option>
							<el-option v-for="item in aslist" :label="item.AskerName" :value="item.AskerId"></el-option>
						</el-select>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button v-on:click="editakdialogFormVisible = false">取 消</el-button>
					<el-button type="primary" @click="SureEditRo">确 定</el-button>
				</div>
			</el-dialog>
			<!-- 查看详细信息 -->
			<el-dialog title="查看" :visible.sync="LookdialogFormVisible">
				<div style="align-items: center;text-align: center;">
					<el-divider><i class="el-icon-cloudy"></i></el-divider>
					<div>姓名：{{looklist.SName}}</div></br>
					<div>性别：{{looklist.Sex}}</div></br>
					<div>年龄：{{looklist.Age}}</div></br>
					<div>手机：{{looklist.Phone}}</div></br>
					<div>QQ：{{looklist.QQ}}</div></br>
					<div>微信：{{looklist.WX}}</div></br>
					<div>地址：{{looklist.SAddress}}</div></br>
					<div>定金：{{looklist.Money}}</div></br>
					<div>来源渠道：{{looklist.MsgScource}}</div></br>
					<div>来源网站：{{looklist.ScourceUrl}}</div></br>
					<div>来源关键字：{{looklist.ScourceKeyWord}}</div></br>
					<div>课程方向：{{looklist.Learnforward}}</div></br>
					<el-divider><i class="el-icon-ship"></i></el-divider>
				</div>
				<div slot="footer" class="dialog-footer">
					<el-button v-on:click="LookdialogFormVisible = false">关闭</el-button>
				</div>
			</el-dialog>
			<!-- 编辑学生信息 -->
			<el-dialog title="编辑学生信息" :visible.sync="editdialogFormVisible">
				<el-form :model="editform">
					<el-form-item label="姓名" label-width="80px">
						<el-input v-model="editform.SName" autocomplete="off"></el-input>
					</el-form-item>
					<el-form-item label="年龄" label-width="80px">
						<el-input v-model="editform.Age" autocomplete="off"></el-input>
					</el-form-item>
					<el-form-item label="性别" label-width="80px">
						<el-input v-model="editform.Sex" autocomplete="off"></el-input>
					</el-form-item>
					<el-form-item label="手机号" label-width="80px">
						<el-input v-model="editform.Phone" autocomplete="off"></el-input>
					</el-form-item>
					<el-form-item label="QQ" label-width="80px">
						<el-input v-model="editform.QQ" autocomplete="off"></el-input>
					</el-form-item>
					<el-form-item label="所有咨询师">
						<el-select v-model="editform.AskerId">
							<el-option label="--所有咨询师--" value="0"></el-option>
							<el-option v-for="item in aslist" :label="item.AskerName" :value="item.AskerId"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="来源渠道" label-width="80px">
						<el-input v-model="editform.MsgScource" autocomplete="off"></el-input>
					</el-form-item>
					<el-form-item label="订金金额" label-width="80px">
						<el-input v-model="editform.Money" autocomplete="off"></el-input>
					</el-form-item>
					<el-form-item prop="IsValid" label="是否无效">
						<el-tooltip content="绿:有效 红:无效" placement="top">
							<el-switch v-model="editform.IsValid" active-color="#13ce66" inactive-color="#ff4949"
								:active-value="1" :inactive-value="0"></el-switch>
						</el-tooltip>
					</el-form-item>
					<el-form-item prop="IsReturnVisit" label="是否回访">
						<el-tooltip content="绿:回访 红:未回访" placement="top">
							<el-switch v-model="editform.IsReturnVisit" active-color="#13ce66" inactive-color="#ff4949"
								:active-value="1" :inactive-value="0"></el-switch>
						</el-tooltip>
					</el-form-item>
					<el-form-item prop="IsHome" label="是否上门">
						<el-tooltip content="绿:上门 红:未上门" placement="top">
							<el-switch v-model="editform.IsHome" active-color="#13ce66" inactive-color="#ff4949"
								:active-value="1" :inactive-value="0"></el-switch>
						</el-tooltip>
					</el-form-item>
					<el-form-item prop="IsPay" label="是否缴费">
						<el-tooltip content="绿:已缴费 红:未缴费" placement="top">
							<el-switch v-model="editform.IsPay" active-color="#13ce66" inactive-color="#ff4949"
								:active-value="1" :inactive-value="0"></el-switch>
						</el-tooltip>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button v-on:click="editdialogFormVisible = false">取 消</el-button>
					<el-button type="primary" @click="SureEdit">确 定</el-button>
				</div>
			</el-dialog>
			<!-- 跟踪 -->
			<el-dialog title="跟踪" :visible.sync="followdialogFormVisible" @close="AFClose">
				<el-form :model="addformFo" ref="addFoFormRef">
					<el-form-item label="学生编号" prop="StudentId" label-width="80px">
						<el-input v-model="addformFo.StudentId" disabled></el-input>
					</el-form-item>
					<el-form-item label="学生姓名" prop="StudentName" label-width="80px">
						<el-input v-model="addformFo.StudentName" disabled></el-input>
					</el-form-item>
					<el-form-item label="跟踪者" prop="UserId" label-width="80px">
						<el-select v-model="addformFo.UserId">
							<el-option v-for="item in asfolist" :label="item.LoginName" :value="item.Id">
							</el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="跟踪内容" prop="NContent" label-width="80px">
						<el-input v-model="addformFo.NContent"></el-input>
					</el-form-item>
					<el-form-item label="跟踪方式" prop="FollowType" label-width="80px">
						<el-select v-model="addformFo.FollowType">
							<el-option label="--面谈--" value="面谈"></el-option>
							<el-option label="--电话--" value="电话"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="回访情况" prop="FollowState" label-width="80px">
						<el-select v-model="addformFo.FollowState">
							<el-option label="--思量--" value="思量"></el-option>
							<el-option label="--上门未报名--" value="上门未报名"></el-option>
							<el-option label="--报名未选班--" value="报名未选班"></el-option>
							<el-option label="--未上门--" value="未上门"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="次访时间" prop="NextFollowTime" label-width="80px">
						<el-input v-model="addformFo.NextFollowTime" disabled></el-input>
					</el-form-item>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button v-on:click="followdialogFormVisible = false">取 消</el-button>
					<el-button type="primary" @click="SureAddFo">确 定</el-button>
				</div>
			</el-dialog>
			<!-- 日志 -->
			<el-dialog title="日志" :visible.sync="dialogFormVisible">
				<el-table :data="netlist" style="width: 100%" max-height="500">
					<el-table-column fixed prop="NId" label="编号" width="100">
					</el-table-column>
					<el-table-column prop="StudentName" label="姓名" width="120">
					</el-table-column>
					<el-table-column prop="FollowState" label="回访情况" width="120">
					</el-table-column>
					<el-table-column prop="FollowType" label="跟踪方式" width="120">
					</el-table-column>
					<el-table-column prop="NContent" label="内容" width="150">
					</el-table-column>
					<el-table-column prop="FollowTime" label="跟踪时间" width="150">
					</el-table-column>
					<el-table-column prop="NextFollowTime" label="下次跟踪时间" width="150">
					</el-table-column>
					<el-table-column fixed="right" label="操作" width="300">
						<template slot-scope="scope">
							<el-button icon="el-icon-thumb" @click.native.prevent="LookRIZHI(scope.row)" type="text"
								size="small">
								查看
							</el-button>
						</template>
					</el-table-column>
				</el-table>
				<div slot="footer" class="dialog-footer">
					<el-button type="primary" v-on:click="dialogFormVisible = false">关闭</el-button>
				</div>
			</el-dialog>
			<!-- 日志里的查看 -->
			<el-dialog title="日志" :visible.sync="rizhidialogFormVisible">
				<div style="align-items: center;text-align: center;">
					<el-divider><i class="el-icon-cloudy"></i></el-divider>
					<div>姓名：{{lookrizhilist.StudentName}}</div></br>
					<div>内容：{{lookrizhilist.NContent}}</div></br>
					<el-divider><i class="el-icon-ship"></i></el-divider>
				</div>
				<div slot="footer" class="dialog-footer">
					<el-button v-on:click="rizhidialogFormVisible = false">关闭</el-button>
				</div>
			</el-dialog>
		</el-card>
	</div>
</template>

<script>
	import FileSaver from 'file-saver';
	import XLSX from 'xlsx';
	export default {
		data() {
			return {
				//搜索
				formInline: {
					SName: '',
					IsPay: '',
					IsValid: '',
					IsReturnVisit: '',
					QQ: '',
					CreateTime1: '',
					CreateTime2: '',
					HomeTime1: '',
					HomeTime2: '',
					Phone: '',
					AskerId: ''
				},
				//搜索里的咨询师
				aslist: [],
				//表格
				tableData: [],
				//分页
				page: 1,
				limit: 5,
				count: 0,
				//批量编辑框的显示
				editakdialogFormVisible: false,
				//批量编辑
				editakform: {
					Name: ''
				},
				//日志
				netlist: [],
				//查看
				looklist: [],
				//日志框的显示
				dialogFormVisible: false,
				//查看框的显示
				LookdialogFormVisible: false,
				//跟踪框的显示
				followdialogFormVisible: false,
				//跟踪
				addformFo: {
					StudentName: '',
					StudentId: '',
					FollowType: '',
					FollowState: '',
					NextFollowTime: '',
					FollowTime: '',
					UserId: '',
					NContent: ''
				},
				//跟踪里的跟踪者
				asfolist: [],
				//编辑框的显示
				editdialogFormVisible: false,
				//编辑
				editform: {
					SName: '',
					IsPay: '',
					IsValid: '',
					IsReturnVisit: '',
					QQ: '',
					Phone: '',
					AskerId: '',
					IsHome: '',
					Money: ''
				},
				TableShow: {
					SId: true,
					SName: true,
					Age: true,
					Sex: true,
					Phone: true,
					AskerName: true,
					SAddress: true,
					QQ: true,
					WX: true,
					StuStatus: true,
					MsgScource: false,
					Money: false,
					ScourceUrl: false,
					ScourceKeyWord: false,
					FromPart: true,
					IsBaoBei: false,
					IsValid: false,
					IsHome: false,
					Record: false,
					IsReturnVisit: false,
					FirstVisitTime: false,
					HomeTime: false,
					LostVaild: false,
					PayTime: false,
					IsReturnMony: false,
					IsInClass: false,
					InClassTime: false,
					InClassContent: false,
					ReturnMoneyReason: false,
					PreMoney: false,
					PreMoneyTime: false,
					IsPay: false,
					NetPushId: true,
					CreateTime: true
				},
				TableRowVisible: false,
				stuaddform: {
					SName:'',
					Sex:'',
					Age:'',
					Phone:'',
					QQ:'',
					MsgScource:'',
					ScourceUrl:'',
					ScourceKeyWord:'',
					AskerId:''
				},
				adddialogFormVisible: false,
				rizhidialogFormVisible:false,
				lookrizhilist:[],
				selectList: [],
				stuadddialogFormVisible:false
			}
		},
		created() {
			this.GetMyStudentList();
			this.GetAskerList();
			this.GetAsFoList();
		},
		methods: {
			AClose() {
				this.$refs.stuaddFormRef.resetFields();
			},
			SUREADD() {
				this.$refs.stuaddFormRef.validate(vali => {
					if (!vali) return;
					let _this = this;
					this.$axios.post('/api/api/MyStudent/AddStu', _this.stuaddform).then(function(res) {
						if (res.data.code == 0) {
							_this.stuadddialogFormVisible = false;
							_this.GetMyStudentList();
							_this.$message.success(res.data.msg);
						} else {
							_this.$message.error(res.data.msg);
						}
					}).catch(function(err) {
						_this.$message.error(res.data.msg);
					})
				})
			},
			handleSelectionChange(row) {
				this.selectList = row; // 将选中的数据给selectList
				console.log(row);
			},
			//导出表格
			downloadExcel() {
				this.$confirm('将导出为excel文件，确认导出?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).then(() => {
					if (this.selectList.length > 0) {
						this.excelData = this.selectList
					} else {
						this.excelData = this.tableData
					}
					this.export2Excel();
				}).catch(() => {
			
				})
			},
			// 数据写入excel
			export2Excel() {
				var that = this
				require.ensure([], () => {
					const {
						export_json_to_excel
					} = require('../../excel/Export2Excel.js') // 这里必须使用绝对路径，使用@/+存放export2Excel的路径
					const tHeader = ['序号', '姓名', '性别', '年龄', '电话', '来源渠道', '咨询师'] // 导出的excel的表头字段
					const filterVal = ['SId', 'SName', 'Sex', 'Age', 'Phone', 'MsgScource',
						'AskerId'
					] // 对象属性，对应于tHeader
					const list = that.excelData //json数组对象，接口返回的数据
					const data = that.formatJson(filterVal, list)
					export_json_to_excel(tHeader, data, '学生表格') // 导出的表格名称
				})
			},// 格式转换，直接复制即可
			formatJson(filterVal, jsonData) {
				return jsonData.map(v => filterVal.map(j => v[j]))
			},
			//打开批量操作
			EditRo() {
				this.editakdialogFormVisible = true;
			},
			//批量操作
			SureEditRo() {
				let _this = this;
				this.axios.post('/api/api/MyStudent/EditAskId', _this.editakform).then(function(res) {
					if (res.data.code == 0) {
						_this.editakdialogFormVisible = false;
						_this.GetMyStudentList();
						_this.$message.success(res.data.msg);
					} else {
						_this.$message.error(res.data.msg);
					}
				}).catch(function(err) {
					_this.$message.error(err.data.msg);
				})
			},
			//搜索
			onSubmit() {
				this.GetMyStudentList();
			},
			//查看
			Look(row) {
				console.log(row);
				this.looklist = row;
				this.LookdialogFormVisible = true;
			},
			LookRIZHI(row) {
				this.lookrizhilist = row;
				this.rizhidialogFormVisible = true;
			},
			//编辑学生信息
			EditStu(row) {
				this.editform = row;
				this.editdialogFormVisible = true;
			},
			//编辑
			SureEdit() {
				let _this = this;
				this.$axios.post('/api/api/MyStudent/EditCheck', _this.editform).then(function(res) {
					if (res.data.code == 0) {
						_this.editdialogFormVisible = false;
						_this.GetMyStudentList();
						_this.$message.success("编辑成功！");
					}
				}).catch(function(err) {
					_this.$message.error("编辑失败！");
				})
			},
			//删除
			async DELETE(SId) {
				const delresult = await this.$confirm('此操作将永久删除该用户, 是否继续?', '删除提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}).catch(err => err)
				if (delresult !== 'confirm') {
					return this.$message.info('已经取消删除！')
				}
				let _this = this;
				_this.$axios.post('/api/api/MyStudent/DelStu', {
					SId: SId
				}).then(function(res) {
					if (res.data.code == 0) {
						_this.GetMyStudentList();
						_this.$message.success("删除成功！");
					} else if (res.data.code == -1) {
						_this.$message.error(res.data.msg);
					} else {
						_this.$message.error(res.data.msg);
					}
				}).catch(function(err) {
					_this.$message.error("删除失败！");
				})

			},
			//打开跟踪框
			AddFollow(row) {
				this.followdialogFormVisible = true;
				this.addformFo.StudentId = row.SId;
				this.addformFo.StudentName = row.SName;
				this.addformFo.NextFollowTime = row.FirstVisitTime;
				this.addformFo.UserId = row.AskerId;
				console.log(row);
			},
			//关闭弹框后清除信息
			AFClose() {
				this.$refs.addFoFormRef.resetFields();
			},
			//确定新建跟踪信息
			SureAddFo() {
				let _this = this;
				this.$axios.post('/api/api/MyStudent/AddFollow', _this.addformFo).then(function(res) {
					if (res.data.code == 0) {
						_this.followdialogFormVisible = false;
						_this.GetMyStudentList();
						_this.$message.success(res.data.msg);
					} else {
						_this.$message.error(res.data.msg);
					}
				}).catch(function(err) {
					_this.$message.error(res.data.msg);
				})
			},
			//获取跟踪者
			GetAsFoList() {
				let _this = this;
				this.$axios.get('/api/api/Follow/GetUsList').then(function(res) {
					console.log(res.data.data);
					_this.asfolist = res.data.data;
				}).catch(function(res) {
					console.log(res);
				});
			},
			//日志
			deleteRow(SId) {
				let _this = this;
				_this.dialogFormVisible = true;
				this.$axios.post('/api/api/MyStudent/GetRiZhiList', {
					SId: SId
				}).then(function(res) {
					console.log(res.data.data);
					_this.netlist = res.data.data;
					_this.count = res.data.count;
				}).catch(function(res) {
					console.log(res);
				});
			},
			//获取学生信息列表
			GetMyStudentList() {
				let _this = this;
				this.$axios.get('/api/api/MyStudent/GetStuList', {
					params: {
						page: _this.page,
						limit: _this.limit,
						SName: _this.formInline.SName,
						IsPay: _this.formInline.IsPay,
						IsValid: _this.formInline.IsValid,
						IsReturnVisit: _this.formInline.IsReturnVisit,
						QQ: _this.formInline.QQ,
						CreateTime1: _this.formInline.CreateTime1,
						CreateTime2: _this.formInline.CreateTime2,
						HomeTime1: _this.formInline.HomeTime1,
						HomeTime2: _this.formInline.HomeTime2,
						Phone: _this.formInline.Phone,
						AskerId: _this.formInline.AskerId
					}
				}).then(function(res) {
					console.log(res.data.data);
					_this.tableData = res.data.data;
					_this.count = res.data.count;
				}).catch(function(res) {
					console.log(res);
				});
			},
			//获取咨询师姓名-搜索下拉框
			GetAskerList() {
				let _this = this;
				this.$axios.get('/api/api/MyStudent/GetAskList').then(function(res) {
					console.log(res.data.data);
					_this.aslist = res.data.data;
				}).catch(function(res) {
					console.log(res);
				});
			},
			//每页数据条数
			handleSizeChange(newSize) {
				console.log(newSize);
				this.limit = newSize;
				this.GetMyStudentList();
			},
			//监听页码值改变
			handleCurrentChange(newPage) {
				console.log(newPage);
				this.page = newPage;
				this.GetMyStudentList();
			}
		}
	}
</script>

<style>
</style>
